# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

_hkgname=rebase
pkgname=haskell-rebase
pkgver=1.18
pkgrel=2
pkgdesc='A more progressive alternative to the "base" package'
url="https://github.com/nikita-volkov/rebase"
license=("MIT")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-bifunctors' 'haskell-contravariant' 'haskell-comonad' 'haskell-dlist'
         'haskell-either' 'haskell-groups' 'haskell-hashable' 'haskell-invariant'
         'haskell-profunctors' 'haskell-scientific' 'haskell-selective' 'haskell-semigroupoids'
         'haskell-time-compat' 'haskell-unordered-containers' 'haskell-uuid-types' 'haskell-vector'
         'haskell-vector-instances' 'haskell-void')
makedepends=('ghc' 'uusi')
source=("https://hackage.haskell.org/packages/archive/${_hkgname}/${pkgver}/${_hkgname}-${pkgver}.tar.gz")
sha512sums=('c6f6fd20eb4fdb9fd8e1aa509c19367583522810373a65d7cd5b29ad684daff4218c8aa093b2b8858d79deb51c82bfabf12c17f795a51d6dd2327dfca0ae7c4f')

prepare() {
    cd $_hkgname-$pkgver
    gen-setup
}

build() {
    cd $_hkgname-$pkgver

    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd $_hkgname-$pkgver

    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
